﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PSL.Package.System
{
    /// <summary>
    /// All available packages in the default system
    /// </summary>
    public enum Packages
    { 
        All = 1,
        String = 2,
        Console = 4,
        Variable = 8,
        IO = 16,
        GUI = 32
    }

    /// <summary>
    /// Package-Manager for the core-packages
    /// </summary>
    public  class PackageManager
    {
        #region Singleton
        private static readonly PackageManager singleton = new PackageManager();

        public static PackageManager Singleton
        {
            get { return PackageManager.singleton; }
        }
        #endregion

        #region Constructor
        /// <summary>
        /// Private Constructor for the package
        /// </summary>
        private PackageManager()
        {

        }
        #endregion

        #region Public Methods
        /// <summary>
        /// Setup packages to the script host
        /// </summary>
        /// <param name="Host">Instance of an script host</param>
        /// <param name="PackageList">Pipe seperated packages</param>
        public void SetupPackages(PSLRuntime Host, Packages PackageList)
        {
            if ((PackageList & Packages.String) == Packages.String || (PackageList & Packages.All) == Packages.All)
            {
                PSL_String.Init(Host);
            }


            if ((PackageList & Packages.Console) == Packages.Console || (PackageList & Packages.All) == Packages.All)
            {
                PSL_Console.Init(Host);
            }


            if ((PackageList & Packages.Variable) == Packages.Variable || (PackageList & Packages.All) == Packages.All)
            {
                PSL_Variable.Init(Host);
            }


            if ((PackageList & Packages.IO) == Packages.IO || (PackageList & Packages.All) == Packages.All)
            {
                PSL_IO.Init(Host);
            }


            if ((PackageList & Packages.GUI) == Packages.GUI || (PackageList & Packages.All) == Packages.All)
            {
                PSL_GUI.Init(Host);
            }
        }
        #endregion
    }
}
